package com.java.lesson.lesson5;

import java.io.IOException;

public class lesson51 {
    public static void main(String[] args) {
        int a = 1;
        int b = 0;
        try {//监控区域
            System.out.println(a/b);
        }catch (ArithmeticException e){
            System.out.println("程序出现异常，变量b不能为0");
        }finally {//finally一般用来处理善后工作
            System.out.println("finally");
        }
    }

    public void text(int a, int b) throws ArithmeticException{
        if (b == 0) {//主动抛出异常 throw 一般用在方法中
            throw new ArithmeticException();
        }
        System.out.println(a/b);
    }

}

